package com.zx.servlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zx.entity.Department;
import com.zx.service.DepartmentService;
import com.zx.service.impl.DepartmentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/DepartmentServlet")
public class DepartmentServlet extends BaseServlet {
    DepartmentService departmentService = new DepartmentServiceImpl();
    public void index (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Department> departments = departmentService.departmentList();
        //System.out.println(departments);
        request.setAttribute("departments",departments);
        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }
}
